﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;

namespace DAL.Linq.EntityMapper
{
    public static class Mapper
    {
        /// <summary>
        /// Maps BANSAOHOADON entity to BANSAOHOADON business object.
        /// </summary>
        /// <param name="objInfo">A BANSAOHOADON entity to be transformed.</param>
        /// <returns>A BANSAOHOADON business object.</returns>
        internal static BANSAOHOADON ToBusinessObject(BANSAOHOADONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new BANSAOHOADON(objInfo.BanSaoHoaDon, objInfo.MaHoaDon, objInfo.SoBanSao, objInfo.NgayIn, objInfo.NguoiIn, objInfo.CreateBy,
                    objInfo.ModifiedBy, objInfo.ModifiedOn);
            //{
            //    BanSaoHoaDon = objInfo.BanSaoHoaDon,
            //    CreateBy = objInfo.CreateBy,
            //    MaHoaDon = objInfo.MaHoaDon,
            //    ModifiedBy = objInfo.ModifiedBy,
            //    ModifiedOn = objInfo.ModifiedOn,
            //    NgayIn = objInfo.NgayIn,
            //    NguoiIn = objInfo.NguoiIn,
            //};
        }

        internal static List<BANSAOHOADON> ToListBusinessObjects(List<BANSAOHOADONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<BANSAOHOADON> lstBusinessObjects = new List<BANSAOHOADON>();
            foreach (BANSAOHOADONInfo obj in lstObjInfo)
            {
                BANSAOHOADON objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps CAUHINHTRANGIN entity to CAUHINHTRANGIN business object.
        /// </summary>
        /// <param name="objInfo">A CAUHINHTRANGIN entity to be transformed.</param>
        /// <returns>A CAUHINHTRANGIN business object.</returns>
        internal static CAUHINHTRANGIN ToBusinessObject(CAUHINHTRANGINInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new CAUHINHTRANGIN(objInfo.ID, objInfo.Left, objInfo.Right, objInfo.Top, objInfo.Bottom, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<CAUHINHTRANGIN> ToListBusinessObjects(List<CAUHINHTRANGINInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<CAUHINHTRANGIN> lstBusinessObjects = new List<CAUHINHTRANGIN>();
            foreach (CAUHINHTRANGINInfo obj in lstObjInfo)
            {
                CAUHINHTRANGIN objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps CONGTY entity to CONGTY business object.
        /// </summary>
        /// <param name="objInfo">A CONGTY entity to be transformed.</param>
        /// <returns>A CONGTY business object.</returns>
        internal static CONGTY ToBusinessObject(CONGTYInfo objInfo)
        {
            if (objInfo == null)
                return null;
            
            return new CONGTY(objInfo.MaCongTy, objInfo.TenCongTy, objInfo.DiaChi, objInfo.DienThoai, objInfo.Fax, objInfo.Website,
                objInfo.TinhThanh, objInfo.QuanHuyen, objInfo.GiamDoc, objInfo.KeToanTruong, objInfo.ThuQuy, objInfo.MST, objInfo.CoQuanThue,
                objInfo.TaiKhoan, objInfo.NganHang, objInfo.MauHD, null, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<CONGTY> ToListBusinessObjects(List<CONGTYInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<CONGTY> lstBusinessObjects = new List<CONGTY>();
            foreach (CONGTYInfo obj in lstObjInfo)
            {
                CONGTY objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }


        /// <summary>
        /// Maps DMDONVITINH entity to DMDONVITINH business object.
        /// </summary>
        /// <param name="objInfo">A DMDONVITINH entity to be transformed.</param>
        /// <returns>A DMDONVITINH business object.</returns>
        internal static DMDONVITINH ToBusinessObject(DMDONVITINHInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMDONVITINH(objInfo.MaDonViTinh, objInfo.MaCode, objInfo.TenDonViTinh, objInfo.IsUse, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMDONVITINH> ToListBusinessObjects(List<DMDONVITINHInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMDONVITINH> lstBusinessObjects = new List<DMDONVITINH>();
            foreach (DMDONVITINHInfo obj in lstObjInfo)
            {
                DMDONVITINH objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMHANGHOA entity to DMHANGHOA business object.
        /// </summary>
        /// <param name="objInfo">A DMHANGHOA entity to be transformed.</param>
        /// <returns>A DMHANGHOA business object.</returns>
        internal static DMHANGHOA ToBusinessObject(DMHANGHOAInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMHANGHOA(objInfo.MaHangHoa, objInfo.TenHangHoa, objInfo.MaDonViTinh, objInfo.DonGia, objInfo.IsUse, objInfo.IsDelete,
               objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMHANGHOA> ToListBusinessObjects(List<DMHANGHOAInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMHANGHOA> lstBusinessObjects = new List<DMHANGHOA>();
            foreach (DMHANGHOAInfo obj in lstObjInfo)
            {
                DMHANGHOA objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMHINHTHUCTHANHTOAN entity to DMHINHTHUCTHANHTOAN business object.
        /// </summary>
        /// <param name="objInfo">A DMHINHTHUCTHANHTOAN entity to be transformed.</param>
        /// <returns>A DMHINHTHUCTHANHTOAN business object.</returns>
        internal static DMHINHTHUCTHANHTOAN ToBusinessObject(DMHINHTHUCTHANHTOANInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMHINHTHUCTHANHTOAN(objInfo.MaHinhThucThanhToan, objInfo.TenHinhThucThanhToan, objInfo.IsUse, objInfo.CreateBy,
                objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMHINHTHUCTHANHTOAN> ToListBusinessObjects(List<DMHINHTHUCTHANHTOANInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMHINHTHUCTHANHTOAN> lstBusinessObjects = new List<DMHINHTHUCTHANHTOAN>();
            foreach (DMHINHTHUCTHANHTOANInfo obj in lstObjInfo)
            {
                DMHINHTHUCTHANHTOAN objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMKHACHHANG entity to DMKHACHHANG business object.
        /// </summary>
        /// <param name="objInfo">A DMKHACHHANG entity to be transformed.</param>
        /// <returns>A DMKHACHHANG business object.</returns>
        internal static DMKHACHHANG ToBusinessObject(DMKHACHHANGInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMKHACHHANG(objInfo.MaKhachHang, objInfo.TenKhachHang, objInfo.TenCongTy, objInfo.DiaChi, objInfo.DienThoai, objInfo.Fax,
                objInfo.Website, objInfo.TaiKhoan, objInfo.MaSoThue, objInfo.IsUse, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMKHACHHANG> ToListBusinessObjects(List<DMKHACHHANGInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMKHACHHANG> lstBusinessObjects = new List<DMKHACHHANG>();
            foreach (DMKHACHHANGInfo obj in lstObjInfo)
            {
                DMKHACHHANG objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }


        /// <summary>
        /// Maps DMLOAITHUE entity to DMLOAITHUE business object.
        /// </summary>
        /// <param name="objInfo">A DMLOAITHUE entity to be transformed.</param>
        /// <returns>A DMLOAITHUE business object.</returns>
        internal static DMLOAITHUE ToBusinessObject(DMLOAITHUEInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMLOAITHUE(objInfo.MaLoaiThue, objInfo.TenLoaiThue, objInfo.IsUse, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMLOAITHUE> ToListBusinessObjects(List<DMLOAITHUEInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMLOAITHUE> lstBusinessObjects = new List<DMLOAITHUE>();
            foreach (DMLOAITHUEInfo obj in lstObjInfo)
            {
                DMLOAITHUE objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMLOAITIENTE entity to DMLOAITIENTE business object.
        /// </summary>
        /// <param name="objInfo">A DMLOAITIENTE entity to be transformed.</param>
        /// <returns>A DMLOAITIENTE business object.</returns>
        internal static DMLOAITIENTE ToBusinessObject(DMLOAITIENTEInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMLOAITIENTE(objInfo.MaLoaiTienTe, objInfo.TenLoaiTienTe, objInfo.IsUse, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);            
        }

        internal static List<DMLOAITIENTE> ToListBusinessObjects(List<DMLOAITIENTEInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMLOAITIENTE> lstBusinessObjects = new List<DMLOAITIENTE>();
            foreach (DMLOAITIENTEInfo obj in lstObjInfo)
            {
                DMLOAITIENTE objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMQUYENHOADON entity to DMQUYENHOADON business object.
        /// </summary>
        /// <param name="objInfo">A DMQUYENHOADON entity to be transformed.</param>
        /// <returns>A DMQUYENHOADON business object.</returns>
        internal static DMQUYENHOADON ToBusinessObject(DMQUYENHOADONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMQUYENHOADON(objInfo.MaQuyenHoaDon, objInfo.TenQuyenHoaDon, objInfo.SoHoaDonTu, objInfo.SoHoaDonDen, objInfo.STT,
                objInfo.IsUse, objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
           
        }

        internal static List<DMQUYENHOADON> ToListBusinessObjects(List<DMQUYENHOADONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMQUYENHOADON> lstBusinessObjects = new List<DMQUYENHOADON>();
            foreach (DMQUYENHOADONInfo obj in lstObjInfo)
            {
                DMQUYENHOADON objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps DMTINHTRANGHOADON entity to DMTINHTRANGHOADON business object.
        /// </summary>
        /// <param name="objInfo">A DMTINHTRANGHOADON entity to be transformed.</param>
        /// <returns>A DMTINHTRANGHOADON business object.</returns>
        internal static DMTINHTRANGHOADON ToBusinessObject(DMTINHTRANGHOADONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new DMTINHTRANGHOADON(objInfo.MaTinhTrangHoaDon, objInfo.TenTinhTrangHoaDon, objInfo.IsUse, objInfo.CreateBy,
                objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<DMTINHTRANGHOADON> ToListBusinessObjects(List<DMTINHTRANGHOADONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<DMTINHTRANGHOADON> lstBusinessObjects = new List<DMTINHTRANGHOADON>();
            foreach (DMTINHTRANGHOADONInfo obj in lstObjInfo)
            {
                DMTINHTRANGHOADON objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps HOADON entity to HOADON business object.
        /// </summary>
        /// <param name="objInfo">A HOADON entity to be transformed.</param>
        /// <returns>A HOADON business object.</returns>
        internal static HOADON ToBusinessObject(HOADONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new HOADON(objInfo.MaQuyenHoaDon, objInfo.SoHoaDon, objInfo.KyHieu, objInfo.NgayTaoHoaDon, objInfo.MaKhachHang, objInfo.MaHinhThucThanhToan,
                objInfo.MaLoaiTienTe, objInfo.MaLoaiThue, objInfo.TenMatHangBan, objInfo.LyDoBanHang, objInfo.SoPhieuThu, objInfo.GiamGia,
                objInfo.ChietKhau, objInfo.TienHangTruocThue, objInfo.TienThue, objInfo.TienHangSauThue, objInfo.TienBangChu, objInfo.MaTinhTrangHoaDon,
                objInfo.NguoiMua, objInfo.NguoiBan, objInfo.ThuTruongDonVi, objInfo.NgayInHD, objInfo.NguoiInHD, objInfo.CreateBy,
                objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<HOADON> ToListBusinessObjects(List<HOADONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<HOADON> lstBusinessObjects = new List<HOADON>();
            foreach (HOADONInfo obj in lstObjInfo)
            {
                HOADON objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps HOADONCHITIET entity to HOADONCHITIET business object.
        /// </summary>
        /// <param name="objInfo">A HOADONCHITIET entity to be transformed.</param>
        /// <returns>A HOADONCHITIET business object.</returns>
        internal static HOADONCHITIET ToBusinessObject(HOADONCHITIETInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new HOADONCHITIET(objInfo.MaHoaDonChiTiet, objInfo.MaHoaDon, objInfo.MaHangHoa, objInfo.MaDonViTinh, objInfo.SoLuong,
                objInfo.DonGia_VND, objInfo.DonGia_NgoaiTe, objInfo.MaLoaiTienTe, objInfo.Thue, objInfo.ThanhTien, objInfo.TuNgay, objInfo.DenNgay,
                objInfo.CreateBy, objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<HOADONCHITIET> ToListBusinessObjects(List<HOADONCHITIETInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<HOADONCHITIET> lstBusinessObjects = new List<HOADONCHITIET>();
            foreach (HOADONCHITIETInfo obj in lstObjInfo)
            {
                HOADONCHITIET objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps HOADONTAM entity to HOADONTAM business object.
        /// </summary>
        /// <param name="objInfo">A HOADONTAM entity to be transformed.</param>
        /// <returns>A HOADONTAM business object.</returns>
        internal static HOADONTAM ToBusinessObject(HOADONTAMInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new HOADONTAM(objInfo.HoaDonTam, objInfo.MaHoaDon, objInfo.MaQuyenHoaDon, objInfo.SoHoaDon, objInfo.STT, objInfo.IsUse, objInfo.CreateBy,
                objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<HOADONTAM> ToListBusinessObjects(List<HOADONTAMInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<HOADONTAM> lstBusinessObjects = new List<HOADONTAM>();
            foreach (HOADONTAMInfo obj in lstObjInfo)
            {
                HOADONTAM objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps HUYHOADON entity to HUYHOADON business object.
        /// </summary>
        /// <param name="objInfo">A HUYHOADON entity to be transformed.</param>
        /// <returns>A HUYHOADON business object.</returns>
        internal static HUYHOADON ToBusinessObject(HUYHOADONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new HUYHOADON(objInfo.HuyHoaDon, objInfo.MaHoaDon, objInfo.SoHoaDon, objInfo.LyDoHuy, objInfo.NgayHuy, objInfo.NguoiHuy, objInfo.CreateBy,
                objInfo.ModifiedBy, objInfo.ModifiedOn);
            
        }

        internal static List<HUYHOADON> ToListBusinessObjects(List<HUYHOADONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<HUYHOADON> lstBusinessObjects = new List<HUYHOADON>();
            foreach (HUYHOADONInfo obj in lstObjInfo)
            {
                HUYHOADON objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_COMMAND entity to SYS_COMMAND business object.
        /// </summary>
        /// <param name="objInfo">A SYS_COMMAND entity to be transformed.</param>
        /// <returns>A SYS_COMMAND business object.</returns>
        internal static SYS_COMMAND ToBusinessObject(SYS_COMMANDInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_COMMAND(objInfo.CommandID, objInfo.CommandName, objInfo.IsUse);
            
        }

        internal static List<SYS_COMMAND> ToListBusinessObjects(List<SYS_COMMANDInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_COMMAND> lstBusinessObjects = new List<SYS_COMMAND>();
            foreach (SYS_COMMANDInfo obj in lstObjInfo)
            {
                SYS_COMMAND objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_FUNC_COMM entity to SYS_FUNC_COMM business object.
        /// </summary>
        /// <param name="objInfo">A SYS_FUNC_COMM entity to be transformed.</param>
        /// <returns>A SYS_FUNC_COMM business object.</returns>
        internal static SYS_FUNC_COMM ToBusinessObject(SYS_FUNC_COMMInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_FUNC_COMM(objInfo.FunctionID, objInfo.CommandID);
            
        }

        internal static List<SYS_FUNC_COMM> ToListBusinessObjects(List<SYS_FUNC_COMMInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_FUNC_COMM> lstBusinessObjects = new List<SYS_FUNC_COMM>();
            foreach (SYS_FUNC_COMMInfo obj in lstObjInfo)
            {
                SYS_FUNC_COMM objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_FUNCTION entity to SYS_FUNCTION business object.
        /// </summary>
        /// <param name="objInfo">A SYS_FUNCTION entity to be transformed.</param>
        /// <returns>A SYS_FUNCTION business object.</returns>
        internal static SYS_FUNCTION ToBusinessObject(SYS_FUNCTIONInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_FUNCTION(objInfo.FunctionID, objInfo.FunctionName, objInfo.FunctionClass, objInfo.IsUse);
            
        }

        internal static List<SYS_FUNCTION> ToListBusinessObjects(List<SYS_FUNCTIONInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_FUNCTION> lstBusinessObjects = new List<SYS_FUNCTION>();
            foreach (SYS_FUNCTIONInfo obj in lstObjInfo)
            {
                SYS_FUNCTION objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_GROUP entity to SYS_GROUP business object.
        /// </summary>
        /// <param name="objInfo">A SYS_GROUP entity to be transformed.</param>
        /// <returns>A SYS_GROUP business object.</returns>
        internal static SYS_GROUP ToBusinessObject(SYS_GROUPInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_GROUP(objInfo.GroupID, objInfo.GroupCode, objInfo.GroupName, objInfo.IsUse);
            
        }

        internal static List<SYS_GROUP> ToListBusinessObjects(List<SYS_GROUPInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_GROUP> lstBusinessObjects = new List<SYS_GROUP>();
            foreach (SYS_GROUPInfo obj in lstObjInfo)
            {
                SYS_GROUP objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_GROUP_COMM entity to SYS_GROUP_COMM business object.
        /// </summary>
        /// <param name="objInfo">A SYS_GROUP_COMM entity to be transformed.</param>
        /// <returns>A SYS_GROUP_COMM business object.</returns>
        internal static SYS_GROUP_COMM ToBusinessObject(SYS_GROUP_COMMInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_GROUP_COMM(objInfo.GroupID, objInfo.FunctionID, objInfo.CommandID);
            
        }

        internal static List<SYS_GROUP_COMM> ToListBusinessObjects(List<SYS_GROUP_COMMInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_GROUP_COMM> lstBusinessObjects = new List<SYS_GROUP_COMM>();
            foreach (SYS_GROUP_COMMInfo obj in lstObjInfo)
            {
                SYS_GROUP_COMM objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_GROUPUSER entity to SYS_GROUPUSER business object.
        /// </summary>
        /// <param name="objInfo">A SYS_GROUPUSER entity to be transformed.</param>
        /// <returns>A SYS_GROUPUSER business object.</returns>
        internal static SYS_GROUPUSER ToBusinessObject(SYS_GROUPUSERInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_GROUPUSER(objInfo.GroupID, objInfo.UserID, objInfo.IsUse);
           
        }

        internal static List<SYS_GROUPUSER> ToListBusinessObjects(List<SYS_GROUPUSERInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_GROUPUSER> lstBusinessObjects = new List<SYS_GROUPUSER>();
            foreach (SYS_GROUPUSERInfo obj in lstObjInfo)
            {
                SYS_GROUPUSER objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_USER entity to SYS_USER business object.
        /// </summary>
        /// <param name="objInfo">A SYS_USER entity to be transformed.</param>
        /// <returns>A SYS_USER business object.</returns>
        internal static SYS_USER ToBusinessObject(SYS_USERInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_USER(objInfo.UserID, objInfo.UserCode, objInfo.UserName, objInfo.UserPass, objInfo.IsUse);
            
        }

        internal static List<SYS_USER> ToListBusinessObjects(List<SYS_USERInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_USER> lstBusinessObjects = new List<SYS_USER>();
            foreach (SYS_USERInfo obj in lstObjInfo)
            {
                SYS_USER objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }

        /// <summary>
        /// Maps SYS_USER_COMM entity to SYS_USER_COMM business object.
        /// </summary>
        /// <param name="objInfo">A SYS_USER_COMM entity to be transformed.</param>
        /// <returns>A SYS_USER_COMM business object.</returns>
        internal static SYS_USER_COMM ToBusinessObject(SYS_USER_COMMInfo objInfo)
        {
            if (objInfo == null)
                return null;
            return new SYS_USER_COMM(objInfo.UserID, objInfo.FunctionID, objInfo.CommandID);
            
        }

        internal static List<SYS_USER_COMM> ToListBusinessObjects(List<SYS_USER_COMMInfo> lstObjInfo)
        {
            if (lstObjInfo == null)
                return null;
            List<SYS_USER_COMM> lstBusinessObjects = new List<SYS_USER_COMM>();
            foreach (SYS_USER_COMMInfo obj in lstObjInfo)
            {
                SYS_USER_COMM objTmp = ToBusinessObject(obj);
                if (objTmp != null && !lstBusinessObjects.Contains(objTmp))
                    lstBusinessObjects.Add(objTmp);
            }
            return lstBusinessObjects;
        }
    }
}
